/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *																 *
 *	r2GLApp - r2 Graphs Library Application						 *
 *																 *
 *	File:		r2GLApp.cpp										 *
 *	Authors:	Rafael Kikuchi ( shinjikik@gmail.com )			 *
 *				Rafael Romeiro ( rafaelromeiro@gmail.com )		 *
 *	Date:		08/09/2008										 *
 *	License:	CC-GNU LGPL										 *
 *				http://creativecommons.org/licenses/LGPL/2.1/	 *
 *	Version:	0.1.0											 *
 *																 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <iostream>
#include <vector>

#include "r2GLApp.h"

void r2GLApp::init (bool Directed, int StructType, string FileName)
{
	cout << "Loading Graph...";
	myGraph = new Graph(FileName.c_str(), Directed, StructType);
	cout << " Done!" << endl;
}

void r2GLApp::go (int StartNode, string FileName)
{
	vector< float > results;
	//vector< vector < int > > paths;
	//vector< float > distances;

	/*cout << "Writing MST...";
	myGraph->WriteMST(( "[" + FileName + "] MST.txt" ).c_str());
	cout << " Done!" << endl;*/

	/*cout << "Writing Connected Components...";
	myGraph->WriteConnComponents(( "[" + FileName + "] Components.txt" ).c_str());
	cout << " Done!" << endl;*/

	cout << "Getting Mean Distance and Diameter...";
	myGraph->GetMeanDistanceAndDiameter(results);
	ofstream output2(( "[" + FileName + "] MeanDistanceAndDiameter.txt" ).c_str());
	output2 << "Mean Distance = " << results[0] << endl;
	output2 << "Diameter = " << results[1] << endl;
	cout << " Done!" << endl;
	output2.close();
	

	/*myGraph->WriteBFSTree("BFS_Tree.txt", StartNode);
	myGraph->WriteDFSTree("DFS_Tree.txt", StartNode);
	myGraph->WriteConnComponents("Components.txt");
	myGraph->WriteCycle("Cycle.txt");

	myGraph->Reverse();
	myGraph->WriteGraph("Reverse.txt");*/
}

void r2GLApp::release (void)
{
	delete myGraph;
}
